import { defineStore } from 'pinia';
import { useShopStore } from './shop'
export const useStore = defineStore("store", {
    state: () => {
        return {
            num: 0,
            name: "xial",
            arr: [1, 2, 3]
        }
    },
    getters: { // 不支持异步
        getNum() {
            console.log('----987---')
            return this.num + 100
        },
        getShopList(){
            console.log('===========')
            console.log(useShopStore)
            console.log(useShopStore())
            return useShopStore().list
        }
    },
    actions: {
        setNum(val) {
            this.num += val
        }       
    },
    // 使用插件开启数据缓存
    persist:{
        enabled:true,
        strategies:[
            {
                key:"my_store",
                Storage:localStorage,
                paths:["num"]
            }
        ]
    }
})
